package com.zilue.payment.gateway.paramter.order;

import com.zilue.payment.gateway.annotation.ParameterFiledCheck;
import com.zilue.payment.gateway.paramter.BaseParameter;
import com.zilue.payment.gateway.paramter.ParameterCheckResult;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * Created by zilue on 2017/3/8.
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PayParameter extends BaseParameter {
    @ParameterFiledCheck(regex = "\\w{0,32}", description = "商户订单号,1-32个字符,字母/数字/_")
    private String order_no;
    @ParameterFiledCheck(regex = "\\w{0,32}", description = "支付系统单号,1-32个字符,字母/数字/_")
    private String out_trade_no;
    @ParameterFiledCheck(regex = "\\w{1,64}", description = "支付授权码,1-32个字符,字母/数字/_")
    private String auth_code;

    @Override
    public ParameterCheckResult complicated() {
        if (StringUtils.isEmpty(order_no) && StringUtils.isEmpty(out_trade_no)) {
            return ParameterCheckResult.createErrorResult("order_no , out_trade_no","两个参数中必须传一个参数");
        }
        return ParameterCheckResult.createSuccess();
    }
}
